import ApiAcceptance from "@/api/acceptance";
import Page from "@/components/common/Page";
import ByButton from "@/components/ui/ByButton";
import useFetch from "@/hooks/useFetch";
import useForm from "@/hooks/useForm";
import QuestionSetting from "@/packageProject/components/QuestionSetting";
import { useRouter } from "@tarojs/taro";

export default () => {
  const { params } = useRouter();
  const intentCustomerId = Number(params.intentCustomerId);
  const quesNaireId = Number(params.quesNaireId);

  const {} = useFetch(ApiAcceptance.acceptanceTemplateList, {
    defaultParams: [{ intentCustomerId }],
  });

  const { data } = useFetch<any[]>(ApiAcceptance.acceptanceTemplateDetail, {
    defaultParams: [{ quesNaireId }],
    onAfter: (res: any) => res.quesNaireContent,
  });

  const { loading, model, setModel } = useForm("");

  // 1
  const handleSubmit = () => {
    console.log("===>>", data);
  };

  return (
    <>
      <Page
        footerSticky
        slotFooter={
          <ByButton className="w-2/3" size="large" onClick={handleSubmit}>
            提交
          </ByButton>
        }
      >
        {data?.map((item) => (
          <QuestionSetting source={item} key={item.quesNaireId} />
        ))}
      </Page>
    </>
  );
};
